Declaring and editing the global variables within the global-variables-editor
How to declare a →global variable within a global-object:
-
Go to tab Variables in the global-variables-editor.
-
From the context menu, select New Variable. Alternative: Press the Ctrl-key and the +-key.
Result: A new global variable is inserted. The type of the selected variable is used, if a variable has been selected. Without any selection, a new global variable of data typeBOOL
is inserted. -
Correct the data of this global variable as requested by selecting this variable and clicking onto the respective column of the variable.
Alternative: Use the respective command provided within the context menu under Edit or press the respective shortcut (if there is any).Column
Command under "Edit"
(Shortcut)Additional information
Name
Name
(F2-key)The name must be an →IEC-identifier.
Section
Section
A section is created in the tab Sections. The definitions of this section are applied to the global variable.
The best practice is to use the content assist to select a section from the list of all existing sections.Point to this column to get a tooltip on the section (e.g. whether the section is defined with
CONSTANT
).Type
Type
Initial value
Initial value
optional: See: "→Initial value"
HW address
HW address
optional; physical address in the →PLC
See "Physical address for global variable".Description
Description
optional; A text with several lines is possible – press Shift+Enter.
If you need the code for a newline in a textual editor, please refer to "Which code is required for a newline in a description or comment?".Comment
Comment
Custom data
Custom data
optional; The input is possible as →JSON-string or as a string primitive within
""
(example:"This is my data"
). -
Enter the requested text.
-
Accept the change by pressing the Enter-key or clicking the primary mouse button outside of the current field. Press the ESC-key, if you want to discard the change.
Restriction for renaming a global or external variable
The corresponding counterpart is not automatically renamed.
This means: When renaming a global variable, the external variable of the same name is not renamed. Likewise when renaming an external variable, the global variable of the same name is not renamed.
Physical address for global variable
Examples for physical addresses:
Example |
Explanation |
---|---|
|
output, byte, 7th element (in the 1st level) |
|
input, bool, 1st element (in the 1st level) |
|
input, bool, 1st element (in the 1st level) |
|
input, word, 3rd element in the 7th "module" in the 5th "rack" of the 2nd "bus" |
If you are using EtherCAT fieldbuses that can be addressed via →EC-Master and →EC-Engineer, see "Accessing hardware IOs via EC-Master and EC-Engineer of Acontis" for information on access of their hardware IOs.
Necessary structure for physical address
Enter a physical address according to this structure:
|
Character |
Meaning |
|
---|---|---|---|
1. |
|
initiates the address |
|
2. |
prefix for location |
defines the location |
|
|
|
input |
|
|
|
output |
|
|
|
memory |
|
3. |
prefix for size |
defines the size |
|
|
|
bool (single bit) |
|
|
|
byte (8 bits) |
|
|
|
word (16 bits) |
|
|
|
double word (32 bits) |
|
|
|
long word (64 bits) |
|
4. |
one or more →unsigned integers
|
defines the address |